﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using AjaxControlToolkit;

public partial class Main_ShopList : System.Web.UI.Page
{
    EncriptManager em = new EncriptManager();
    ShopDao sd = new ShopDao();
    DataTable dt = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            try
            {
                if (em.Decript(Request.QueryString["fid"]) == null || Request.QueryString["fid"] == null)
                {
                    Response.Redirect("Shop.aspx");
                }
            }
            catch
            {
                Response.Redirect("Shop.aspx");
            }
            string fid = em.Decript(Request.QueryString["fid"]);
            try
            {
                int id = Convert.ToInt32(fid);
            }
            catch
            {
                Response.Redirect("Shop.aspx");
            }
            labtitle.Text = sd.getFieldName(fid);
            SetPageData(fid, dlshop);
        }
    }

    private void SetPageData(string fid, DataList dl)
    {
        dt = sd.getShop(fid, "0", "","0");
        dl.DataSource = dt;
        dl.DataBind();
        if (dt != null)
        {
            for (int i = 0; i < dl.Items.Count; i++)
            {
                Rating ThaiRating = dl.Items[i].FindControl("ThaiRating") as Rating;
                int hot = Convert.ToInt32(dt.Rows[i][11]);
                ThaiRating.MaxRating = hot;
                ThaiRating.CurrentRating = hot;
                HiddenField Hiddengid = dl.Items[i].FindControl("Hiddengid") as HiddenField;
                HyperLink Hlkshop = dl.Items[i].FindControl("Hlkshop") as HyperLink;
                ImageButton Imbtnimage = dl.Items[i].FindControl("Imbtnimage") as ImageButton;
                string sid = em.Encript(Hiddengid.Value);
                Hlkshop.NavigateUrl = "ShopInfo.aspx?sid=" + sid;
                Imbtnimage.PostBackUrl = "ShopInfo.aspx?sid=" + sid;
            }
        }
    }
}
